package hbnu;

import java.util.Scanner;

public class test5 {
    public static void main(String[] args) {
        int [] num={31,28,31,30,31,30,31,31,30,31,30,31};
        Scanner sc = new Scanner(System.in);
        int year =sc.nextInt();
        int month =sc.nextInt();
        int days =sc.nextInt();
        int sum=0;
        for(int i=0;i<month-1;i++) {
            sum+=num[i];
        }
        if((year%4==0&&year%100!=0)||year%400==0){
            if(month>2){
                sum+=1;
            }
        }
        sum+=days;
        System.out.println(sum);
    }
}
